package com.hmusic.mymusic.service.impl;

import com.hmusic.mymusic.dao.CommentMapper;
import com.hmusic.mymusic.domain.Comment;
import com.hmusic.mymusic.domain.Singer;
import com.hmusic.mymusic.service.CommentService;
import com.hmusic.mymusic.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评论service实现类
 */
@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    /**
     * 添加评论
     *
     * @param comment
     */
    @Override
    public void insert(Comment comment) {
        comment.setCreate_time(DateUtil.getDate());
        commentMapper.insert(comment);
    }

    /**
     * 修改评论
     *
     * @param comment
     */
    @Override
    public void update(Comment comment) {
        commentMapper.update(comment);
    }

    /**
     * 删除评论
     *
     * @param id
     */
    @Override
    public void delete(String id) {
        commentMapper.delete(id);
    }

    /**
     * 根据主键查询整个对象
     *
     * @param id
     */
    @Override
    public Singer selectByPrimaryKey(String id) {
        return commentMapper.selectByPrimaryKey(id);
    }

    /**
     * 根据歌曲id查询
     *
     * @param song_id
     */
    @Override
    public List<Comment> commentOfSongId(String song_id) {
        return commentMapper.commentOfSongId(song_id);
    }

    /**
     * 根据歌单id查询
     *
     * @param song_list_id
     */
    @Override
    public List<Comment> commentOfSongListId(String song_list_id) {
        return commentMapper.commentOfSongListId(song_list_id);
    }

    /**
     * 计算歌曲评论数量
     *
     * @param song_id
     */
    @Override
    public int CountSongComment(String song_id) {
        return commentMapper.CountSongComment(song_id);
    }

    /**
     * 计算歌单评论数量
     *
     * @param song_list_id
     */
    @Override
    public int CountSongListComment(String song_list_id) {
        return commentMapper.CountSongListComment(song_list_id);
    }
}
